<script setup type="ts">
import {
    Avatar,
    Service,
    Management,
    User,
    SwitchButton,
    CaretBottom,
    Files
} from '@element-plus/icons-vue'
import {ref} from 'vue';
import {useRouter} from "vue-router";
import avatar from '@/assets/default.png'
import useUserStore from '@/stores/userStore';
import { getMediatorById } from '@/axios/mediator/mediatorReq';
import useFileStore from '@/stores/fileStore';
let fileStore=useFileStore();
let userStore=useUserStore();
let mediatorId=userStore.userId;
let mediatorName=ref("");

getMediatorById(mediatorId).then(m=>{
   mediatorName.value=m.name;
})
let router=useRouter();
</script>

<template>
    <!-- element-plus 容器 -->
    <el-container class="layout-container">
        <!-- 左侧菜单 -->
        <el-aside width="200px">
            <div class="el-aside__logo"></div>
            <!-- element-plus 菜单标签 -->
            <el-menu active-text-color="#ffd04b" background-color="#232323"  text-color="#fff">
                <el-menu-item index="1" @click="router.push('/mediator/firstPage')">
                    <el-icon>
                        <Avatar />
                    </el-icon>
                    <span>首页</span>
                </el-menu-item>
                <el-sub-menu index="2">
                    <template #title>
                        <el-icon>
                            <Management />
                        </el-icon>
                        <span>个人案件管理</span>
                    </template>
                    <el-menu-item index="2-0" @click="router.push('/mediator/caseUnCompleted')">
                        <el-icon>
                            <Service />
                        </el-icon>
                        <span>未完结</span>
                    </el-menu-item>
                    <el-menu-item index="2-1" @click="router.push('/mediator/caseCompleted')">
                        <el-icon>
                            <Service />
                        </el-icon>
                        <span>已完结</span>
                    </el-menu-item>
                    <el-menu-item index="2-2" @click="router.push('/mediator/paymentHistory')">
                        <el-icon>
                            <Service />
                        </el-icon>
                        <span>待审批还款情况</span>
                    </el-menu-item>
                </el-sub-menu>
                <el-menu-item index="3"@click="router.push('/mediator/userMessage')">
                    <el-icon>
                        <Management />
                    </el-icon>
                    <span>个人资料</span>
                </el-menu-item>
            </el-menu>
        </el-aside>
        <!-- 右侧主区域 -->
        <el-container>
            <!-- 头部区域 -->
            <el-header>
                <div>调解员用户：<strong>{{mediatorName}}</strong></div>
                <!-- 下拉菜单 -->
                <el-dropdown placement="bottom-end">
                    <span class="el-dropdown__box">
                        设置
                        <el-icon>
                            <CaretBottom />
                        </el-icon>
                    </span>
                    <template #dropdown>
                        <el-dropdown-menu>
                            <el-dropdown-item command="logout" :icon="SwitchButton" @click="()=>{
                                userStore.clear();
                                router.push('/login');
                            }">退出登录</el-dropdown-item>
                        </el-dropdown-menu>
                    </template>
                </el-dropdown>
            </el-header>
            <!-- 中间区域 -->
            <el-main>
                <!-- <div style="width: 1290px; height: 570px;border: 1px solid red;">
                    内容展示区
                </div> -->
                <router-view></router-view>
            </el-main>
            <!-- 底部区域 -->
            <el-footer>法院调解平台 ©2024 Created by 02</el-footer>
        </el-container>
    </el-container>
</template>

<style lang="scss" scoped>

.layout-container {
    height: 100vh;
    .el-aside {
        background-color: #232323;

        &__logo {
            height: 120px;
            background: url('@/assets/logo.png') no-repeat center / 200px auto;
        }

        .el-menu {
            border-right: none;
        }
    }

    .el-header {
        background-color: #fff;
        display: flex;
        align-items: center;
        justify-content: space-between;

        .el-dropdown__box {
            display: flex;
            align-items: center;

            .el-icon {
                color: #999;
                margin-left: 10px;
            }

            &:active,
            &:focus {
                outline: none;
            }
        }
    }

    .el-footer {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        color: #666;
    }
}
</style>